@echo off
setlocal enabledelayedexpansion
set "CURRENT_DIR=%~dp0"
set "JRE_HOME=%CURRENT_DIR%jre"
set "PATH=%JRE_HOME%\bin;%PATH%"
echo ===================================================
echo Weaver Game - Command Line Version
echo ===================================================
echo.



REM Check if dictionary.txt exists
if not exist dictionary.txt (
    echo Dictionary file not found. Checking in other locations...
    
    if exist src\main\resources\dictionary.txt (
        echo Found dictionary file in resources folder. Copying...
        copy src\main\resources\dictionary.txt .
    ) else (
        echo WARNING: Dictionary file not found. The game may not work properly.
    )
)

echo Starting Weaver Game (Command Line Version)...
echo.
echo If the game doesn't start, please check the log file: weaver_cli_log.txt
echo.

REM Try to run the game using the JAR file
if exist weaver-game.jar (
    java -cp weaver-game.jar com.weaver.WeaverCLI
) else (
    REM If JAR file doesn't exist, try to run from compiled classes
    if exist com\weaver\WeaverCLI.class (
        java com.weaver.WeaverCLI
    ) else (
        REM If compiled classes don't exist, try to compile and run
        if exist src\main\java\com\weaver\WeaverCLI.java (
            echo Compiling the game...
            mkdir -p com\weaver
            javac -d . src\main\java\com\weaver\*.java src\main\java\com\weaver\*\*.java
            java com.weaver.WeaverCLI
        ) else (
            echo ERROR: Could not find the game files.
            pause
            exit
        )
    )
)

pause